package com.theanh.RssActivity.entity;

import java.util.Date;

import android.graphics.Bitmap;

import com.theanh.RssActivity.util.StringUtils;

public class Item implements Comparable<Item>{

	private int id;
	private String title;
	private String description;
	private String url;
	private Date publishDate;
	private String author;
	private int channelID;
	private boolean readed = false;
	private Bitmap image = null;
	private String imageUrl;

	public String getImageUrl() {
		return imageUrl;
	}

	public void setImageUrl(String imageUrl) {
		this.imageUrl = imageUrl;
	}

	public Bitmap getImage() {
		return image;
	}

	public void setImage(Bitmap image) {
		this.image = image;
	}

	public Item() {

	}

	public Item(int id, String title, String description, String url,
			Date publishDate, String author, int itemID) {
		this.id = id;
		this.title = title;
		this.description = description;
		this.url = url;
		this.publishDate = publishDate;
		this.author = author;
		this.channelID = itemID;
	}

	public String getAuthor() {
		return author;
	}

	public int getChannelID() {
		return channelID;
	}

	public String getDescription() {
		return description;
	}

	public int getID() {
		return id;
	}

	public Date getPublishDate() {
		return publishDate;
	}

	public String getTitle() {
		return title;
	}

	public String getUrl() {
		return url;
	}

	public boolean isReaded() {
		return readed;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public void setChannelID(int itemID) {
		this.channelID = itemID;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public void setID(int id) {
		this.id = id;
	}

	public void setPublishDate(Date publishDate) {
		this.publishDate = publishDate;
	}

	public void setReaded(boolean readed) {
		this.readed = readed;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public void setUrl(String url) {
		this.url = url;
	}
	
	public String toString() {
		return "ID=" + id + ", Title=" + title + ", Url=" + url + ", Channel=" + channelID
				+ ", PublishDate=" + publishDate;
	}


	public boolean validate() {
		if (StringUtils.isNullOrEmpty(title)
				|| StringUtils.isNullOrEmpty(url)) {
			return false;
		}
		return true;
	}

	@Override
	public int compareTo(Item item) {
		if (item == null)
			return 1;
		return item.getPublishDate().compareTo(this.getPublishDate());
	}
}
